package com.bw.mallshop.mvvm.view;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.bw.common.mvvm.view.BaseActivity;
import com.bw.mallshop.BR;
import com.bw.mallshop.R;
import com.bw.mallshop.databinding.ActivityAddressBinding;
import com.bw.mallshop.field.EventAction;
import com.bw.mallshop.mvvm.viewmodel.ShipAddressListViewModel;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class ShipAddressListActivity extends BaseActivity<
        ActivityAddressBinding, ShipAddressListViewModel> {
    @Override
    protected int createvariableId() {
        return BR.vm;
    }

    @Override
    public int bindlayout() {
        return R.layout.activity_address;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        vm.refreshShip();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void shipRefresh(EventAction action){
        if (action.action.equals("ship_refresh")){
            vm.refreshShip();
        }
    }
}
